﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XWG.JWBST.ProcessInterfaces;
using System.IO;
using System.Web;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace XWG.JWBST.LawGuideProcess
{
    /// <summary>
    /// 法律法规和办事指南热点
    /// </summary>
    public class Process : IProcess
    {
        public string ProcessData(StreamReader reader, HttpContext context)
        {
            string info = reader.ReadToEnd();
            info = HttpUtility.UrlDecode(info);
            JObject oka = (JObject)JsonConvert.DeserializeObject(info);
            string function = oka["Function"].ToString().Replace("\"", string.Empty);
            if (function == "Up")
            {
                //更新
                return "更新";
            }
            else
            { 
                //热点
                Hot hot = new Hot();
                hot.KEY_BSZN_FAQ_IDS = XWG.JWBST.JWBSTBLL.TbBstBsznBLL.IsHotSpot();
                hot.KEY_FLFG_FAQ_IDS = XWG.JWBST.JWBSTBLL.TbBstFlfgBLL.FlfgHot();
                IsoDateTimeConverter dtConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
                string json = JsonConvert.SerializeObject(hot,dtConverter);

                return json;
            }
        }

        public class Hot
        {
            private List<string> key_flfg_faq_ids
                ;

            public List<string> KEY_FLFG_FAQ_IDS
            {
                get { return key_flfg_faq_ids; }
                set { key_flfg_faq_ids = value; }
            }
            private List<string> key_bszn_faq_ids
                ;

            public List<string> KEY_BSZN_FAQ_IDS
            {
                get { return key_bszn_faq_ids; }
                set { key_bszn_faq_ids = value; }
            }
        }
    }
}
